package rozetka.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

/**
 * Created by foneox on 06.04.2014.
 */
public class CartModalPage extends BasePage {
    By checkoutButtonLocator = By.id("popup-checkout");
    By quantityFieldLocator = By.name("quantity");
    public CartModalPage(WebDriver driver) {
        super(driver);
    }

    public CheckoutPage checkout() {
        driver.findElement(checkoutButtonLocator).click();
        return new CheckoutPage(driver);

    }

    public void setQuantity(String quantity) {
        WebElement quantityField = driver.findElement(quantityFieldLocator);
        quantityField.clear();
        quantityField.sendKeys(quantity);
        quantityField.sendKeys(Keys.ENTER);
    }
    public String getQuantity() {
        WebElement quantityField = driver.findElement(quantityFieldLocator);
        return quantityField.getAttribute("Value");
    }

}
